/*
*    Phantom v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
// ssi_ostream.cpp: implementation of the ssi_ostream class.
//
//////////////////////////////////////////////////////////////////////

#include "ssi_stream.h"
#include "ssi_stream.h"
#include <stdarg.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


// The following need to be defined outside the library?
//   Perhaps kept as a default Library?
// CConsole
// CScript


ssi_stream::ssi_stream()
{

}

ssi_stream::~ssi_stream()
{

}

void ssi_stream::operator <<(const char* In){
}

void ssi_stream::operator >>(const char* In){
}

void ssi_stream::Disp(const char *In, SSI_BOOL bAddNewLine)
{
}

SSI_INT64 ssi_stream::getline(SSI_CHAR* Buff, SSI_INT64 sz)
{
	return 0;
}

SSI_INT64 ssi_stream::getDebug(SSI_INT64 LineNum, const SSI_CHAR* File, SSI_CHAR* Buff, SSI_INT64 sz)
{
	Disp("DEBUG >>");
	return getline(Buff, sz);
}

void ssi_stream::LogDisp(const char* In, SSI_BOOL bAddLine)
{
	Disp(In, bAddLine);
}

void ssi_stream::ErrorDisp(const char* In, SSI_BOOL bAddLine)
{
	Disp(In, bAddLine);
}

void ssi_stream::WarningDisp(const char* In, SSI_BOOL bAddLine)
{
	Disp(In, bAddLine);
}

void ssi_stream::FailureDisp(const char* In, SSI_BOOL bAddLine)
{
}

int ssi_stream::getLocalFile(const String& FileName, String& LocName)
{
	LocName = FileName;
	return 1;
}

SSI_INT64 ssi_stream::DisplayDebugVariable(String& Value)
{
  Disp(Value.Str(), 1);
  return 1;
}

SSI_INT64 ssi_stream::Format(const SSI_CHAR *fmt, ...)
{
  //String s;
  //va_list vl;
  //va_start( vl, fmt);

  //s.Format(fmt, vl);
  //va_end(vl);
  //Disp(s.Str(), 1);
  //return 1;
  
  
	SSI_CHAR Temp[4096];
	va_list vl;

	va_start( vl, fmt );
	_vsnprintf(Temp, 4096, fmt, vl);
	va_end(vl);

	SSI_INT64 Len = strlen(Temp);
  if(Len > 4096){
    return 0;
  }
  Temp[Len] = 0;
  Disp(Temp, 1);
  return 1;
}


